//
//  TabkeCell.swift
//  AliBaiChuan
//
//  Created by 郑东喜 on 2017/2/8.
//  Copyright © 2017年 郑东喜. All rights reserved.
//  用户信息cell

import UIKit

let W = UIScreen.main.bounds.width
let H = UIScreen.main.bounds.height
let margin : CGFloat = 10

class TabkeCell: UITableViewCell {

    lazy var imgView : UIImageView = {
        let ingView = UIImageView.init(frame: CGRect.init(x: W * 0.5, y: margin, width: W * 0.25, height: W * 0.25))
        ingView.contentMode = .scaleAspectFit
        

        ///展位图
        ingView.image = UIImage.init(named: "holder")
        
        //拿出图片
        if ALBBSession.sharedInstance().isLogin() == true {
            
            print("\((#file as NSString).lastPathComponent):(\(#line))")
            
            if localSave.object(forKey: "loginStatus") == nil {

            } else {
                let dic = localSave.object(forKey: "loginStatus") as? NSMutableArray
                
                let headUrl = dic?.object(at: 3) as? String
                
                DispatchQueue.main.async {
                    
                    do {
                        ingView.image = try UIImage.init(data: Data.init(contentsOf: URL.init(string:headUrl!)!))
                    } catch {
                        
                    }
                }
                
            }
        } else {
            print("\((#file as NSString).lastPathComponent):(\(#line))")
            
            DispatchQueue.main.async {
                
                do {
                    ingView.image = try UIImage.init(data: Data.init(contentsOf: URL.init(string: GetUserModel.shared.avatra)!))
                } catch {
                    
                }
            }
        }
        
        
        
        return ingView
    }()
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: .default, reuseIdentifier: "cellID")
     
        addSubview(imgView)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
